package com.mxpio.erp.inventory.provider;

import com.mxpio.erp.common.inventory.entity.Warehouse;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.jpa.query.Criterion;
import com.mxpioframework.jpa.query.Operator;
import com.mxpioframework.jpa.query.SimpleCriterion;
import com.mxpioframework.security.access.datascope.provider.DataScapeProvider;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author : wpp
 * @Datetime : 2023/4/19 16:31
 * @Desc :
 * @Modor :  Modifytime:
 * @modDesc : 原材料仓过滤器
 */
@Component
public class MaterialsWarehouseProvider implements DataScapeProvider {
    @Override
    @Transactional(readOnly = true)
    public List<Criterion> provide() {
        List<Criterion> appendCriterions = new ArrayList<>();
        appendCriterions.add(new SimpleCriterion("whCode", Operator.EQ,"WH0001"));
        /*Warehouse one = JpaUtil.linq(Warehouse.class).equal("whName", "原材料仓").findOne();
        if (one!=null){
            appendCriterions.add(new SimpleCriterion("whCode", Operator.EQ,one.getWhCode()));
        }else{
            appendCriterions.add(new SimpleCriterion("createTime", Operator.EQ,new Date(0)));//如果未匹配到过滤条件，则增加一个不能正常匹配到数据的条件
        }*/
        return appendCriterions;
    }
}
